<template>
  <el-tree :data="menus" :props="defaultProps" node-key="catId" ref="tree" @node-click="nodeClick">
  </el-tree>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      menus: [], // 三级分类数据
      defaultProps: {
        children: "children", // 子节点对象
        label: "name", // 数据名称
      },
      expandedKey: [], // 默认选中的数组
    };
  },
  computed: {},
  watch: {},
  methods: {
    /**
     * 函数描述：获取三级分类所有菜单
    */
    getMenus() {
      this.$http({
        url: this.$http.adornUrl("/product/category/list/tree"),
        method: "get",
      }).then(({ data }) => {
        this.menus = data.data;
      });
    },
    /**
     * el-tree 点击事件
     * @param: data 数据 
     * @param：node 节点
     * @param：component 组件本身
     */
    nodeClick(data,node,component) {
      this.$emit('tree-node-click',data,node,component);
    }
  },
  created() {
    this.getMenus();
  },
  mounted() {},
};
</script>
<style lang='scss'  scoped>
</style>